import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../pages/Home'
import Main from '../components/Main'
import Supplier from '../pages/Supplier.vue'
import Vip from '../pages/Vip.vue'
import Login from '../pages/Login.vue'
import Inventory from '../pages/Inventory.vue'
import UserInformation from '../pages/UserInformation'
import Market from '../pages/Market.vue'
import PIM from '../pages/PIM.vue'
import Clock from '../pages/user/Clock.vue'
import Register from '../pages/Register.vue'
// import userHome from '../pages/user/Home.vue'
import Leave from '../pages/user/Leave.vue'
import LeaveManagement from '@/pages/LeaveManagement';
import Salary from '@/pages/user/Salary';
import AttendanceManagement from '../pages/AttendanceManagement.vue';
import ClockManagement from '@/pages/ClockManagement.vue';
import UserSalary from '@/pages/user/UserSalary'


Vue.use(VueRouter)

const routes = [{
  path: '/',
  component: Main,
  redirect: "/home",
  children: [{
      path: '/supplier',
      name: 'supplier',
      component: Supplier,
      mate: {
        title: '供应商管理'
      }
    }, {
      path: '/home',
      name: 'home',
      component: Home,
      mate: {
        title: '首页'
      }
    }, {
      path: '/vip',
      name: 'vip',
      component: Vip,
      mate: {
        title: '会员管理'
      }
    }, {
      path: '/inventory',
      name: 'inventory',
      component: Inventory,
      mate: {
        title: '库存管理'
      }

    }, {
      path: '/userInformation',
      name: 'userInformation',
      component: UserInformation,
      mate: {
        title: '用户信息'
      }

    }, {
      path: '/market',
      name: 'market',
      component: Market,
      mate: {
        title: '订单管理'
      }

    }, {
      path: '/pim',
      name: 'pim',
      component: PIM,
      mate: {
        title: '个人信息管理'
      }

    }, {
      path: '/clock',
      name: 'clock',
      component: Clock
    },
    {
      // 请假销假
      path: '/leave',
      name: 'leave',
      component: Leave
    },
    {
      path: '/leavemarket',
      name: 'leavemarket',
      component: LeaveManagement
    },
    {
      path: '/salary',
      name: 'salary',
      component: Salary
    },
    {
      path: '/attendance',
      name: 'attendance',
      component: AttendanceManagement
    },
    {
      path: '/clock-management',
      name: 'clock-management',
      component: ClockManagement
    },
    
    {
      path: '/userSalary',
      name: 'userSalary',
      component: UserSalary
    }
  ]
}, {
  path: '/login',
  name: 'login',
  component: Login
}, {
  path: '/register',
  name: 'register',
  component: Register
}]

const router = new VueRouter({
  routes
})

//挂载路由导航守卫
// router.beforeEach((to, form, next) => {
//   if (to.path == '/login') return next();
//   if (to.path == '/register') return next();
//   const userFlag = window.sessionStorage.getItem("username");
//   if (!userFlag) return next('/login'); //无值 返回登录页
//   next();
// })

export default router